
// Source File Name:   MessageUtils.java

package com.sunwayhorizo.health.hl7.common;


public class MessageUtils
{

    public static final String RCS_ID = "$Header: MessageUtils.java 115.1 2005/05/09 09:55:05 amchanda noship $";
    public static final boolean RCS_ID_RECORDED = VersionInfo.recordClassVersion("$Header: MessageUtils.java 115.1 2006/05/09 09:55:05 amchanda noship $", "com.sunwayhorizo.health.hl7.common");

    public static String getMessage(String s, String as[], String as1[])
    {
        if(as == null || as1 == null)
            return s;
        String s1 = s;
        for(int i = 0; i < as.length; i++)
        {
            StringBuffer stringbuffer = new StringBuffer();
            String s2 = as[i];
            String s3 = "&" + s2;
            if(as1.length > i)
                s3 = as1[i];
            int j = 0;
            for(int k = s1.indexOf("&" + s2); k != -1; k = s1.indexOf("&" + s2, k + s2.length()))
            {
                stringbuffer.append(s1.substring(j, k));
                stringbuffer.append(s3);
                j = k + s2.length() + 1;
            }

            stringbuffer.append(s1.substring(j));
            s1 = stringbuffer.toString();
        }

        return s1;
    }

    public MessageUtils()
    {
    }

}
